package com.cf.service.impl;

import com.cf.dao.AccountTypeDao;
import com.cf.dao.AccountTypeIdTypeDao;
import com.cf.entity.AccountTypeIdType;
import com.cf.service.AccountTypeIdTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AccountTypeIdTypeServiceImpl implements AccountTypeIdTypeService {
    @Autowired
    private AccountTypeIdTypeDao accountTypeIdTypeDao;
    @Override
    public List<AccountTypeIdType> selectAllAccountTypeAndidType() {
        return accountTypeIdTypeDao.selectAllAccountTypeAndidType();
    }

    @Override
    public int updateAccountTypeAndidType(AccountTypeIdType accountTypeIdType) {
        int i1 = accountTypeIdTypeDao.selectById(accountTypeIdType);
        int num = 0;
        if (i1==1){
            num = accountTypeIdTypeDao.delAccountTypeAndidType(accountTypeIdType);
        }else{
            num = accountTypeIdTypeDao.addAccountTypeAndidType(accountTypeIdType);
        }
        return num;
    }

    @Override
    public List<AccountTypeIdType> selectByaccountid(long accountid) {
        return accountTypeIdTypeDao.selectByaccountid(accountid);
    }

    @Override
    public List<AccountTypeIdType> selectBypapersid(long papersid) {
        return accountTypeIdTypeDao.selectBypapersid(papersid);
    }


}
